#include "gui/layers/InfoLayer.h"
#include "gui/objects/GUIHud.h"

namespace gui {

InfoLayer::InfoLayer(CarController* carController, RouteController* routeController) {
	this->carController = carController;
	this->routeController = routeController;
	this->carController->addObserver(this);
	this->routeController->addObserver(this);
	GUIHud guiHud(this->carController, this->routeController);
	this->updateSurface(guiHud);
}

InfoLayer::~InfoLayer() {

}

/*
 * Devuelve siempre la misma porcion ya que la capa de informacion esta siempre presente en el
 * mismo lugar.
 */
Surface* InfoLayer::getPortion(Portion portion) {
	Surface* ret = new Surface(portion.w, portion.h, 0, 0, 255);
	Portion hudPortion;
	hudPortion.x = 0;
	hudPortion.y = 0;
	hudPortion.w = this->completeSurface->getWidth();
	hudPortion.h = this->completeSurface->getHeight();
	ret->applySurface(this->completeSurface, hudPortion);
	ret->setTransparentColor(0, 0, 255);
	return ret;
}

void InfoLayer::notify() {
	GUIHud guiHud(this->carController, this->routeController);
	this->updateSurface(guiHud);
}

}
